//
//  BKNewInteractiveView.h
//  BukaLive
//
//  Created by 曹飞 on 2017/12/7.
//  Copyright © 2017年 曹飞. All rights reserved.
//



/*
 包含流头像管理 主动被动的设置样式，位移，并将回调发送给上层

 添加
 删除
 上下布局
 单个拖动布局
 
 包含文档管理 主动被动的设置样式，位移，并将回调发送给上层
 包含房间号
 包含悬浮按钮管理 并将回调发送给上层
 
 */



#import <UIKit/UIKit.h>

#import "BKButton.h"
#import "BKLiveSubView.h"
#import "BKGestureWebView.h"
#import "BKBrashModel.h"
#import "BKRespondView.h"
#import "BKInteractiveRoomIDView.h"
#import "BKHandsView.h"
#import "BKRoomStatusView.h"
#import "BKPenLaserView.h"



typedef NS_ENUM(NSInteger,BKNewInteractiveViewUser){
    BKNewInteractiveViewUserTeacher,
    BKNewInteractiveViewUserStudent,
};
/*
 悬浮按钮,有多种样式
 */
typedef NS_ENUM(NSInteger,BKNewHoverButtonType) {
    BKNewHoverButtonTypeTeacher,             //老师样式
    BKNewHoverButtonTypeStudentUnauthorized, //学生样式（未授权）
    BKNewHoverButtonTypeStudentAuthorized,   // 学生样式（已授权）
    BKNewHoverButtonTypeListener            //隐形人旁听
};

typedef NS_ENUM(NSInteger,BKNewInteractiveDoubleType){
    BKNewInteractiveDoubleTypeFull, //双击全屏操作
    BKNewInteractiveDoubleTypeFullBack, //双击全屏恢复原始位置操作
    BKNewInteractiveDoubleTypeMoveBack //移出操作
};

typedef void (^BKNewInteractiveViewWhiteBoardDidReceiveScriptMessage)(WKUserContentController *userContentController,WKScriptMessage * message);


typedef void (^BKinteractiveViewHandsUpBlock)(BOOL handsUP); //举手回调
typedef void (^BKinteractiveViewDidMenu)(NSInteger index);
typedef void (^BKinteractiveViewThirdDidMenu)(BOOL brushStatus); //告诉外部现在是画笔状态还是选择状态 YES 画笔 NO 选择
typedef void (^BKinteractiveViewDidDelete)(void); //删除按钮回调
typedef void (^BKinteractiveViewDidWebCloseBtn)(BKHtmlPptModel *webPptModel); //点击web上关闭按钮
typedef void (^BKNewInteractiveDouble)(BKNewInteractiveDoubleType type, id view, UIPanGestureRecognizer *pan);


typedef void (^BKNewInteractiveAudioBlock) (BKHtmlPptModel *PptModel,float currentTime,float total,BOOL isPlay);
typedef void (^BKNewInteractiveVideoBlock) (BKHtmlPptModel *PptModel,float currentTime,float total,BOOL isPlay);


//文档加载画笔的所有情况返回给上层，让上层发送信令


@interface BKNewInteractiveView : UIView


@property (nonatomic,strong) BKRoomStatusView * roomStatusView; //主要是学生短使用

@property (nonatomic,strong) BKInteractiveRoomIDView * roomIdView;
//@property (nonatomic,strong) BKFileSelecterView * fileSelecterView;
@property (nonatomic,strong) BKButton * chatBtn;
@property (nonatomic,strong) BKButton * outRoomBtn;
@property (nonatomic, strong) BKButton *addUserBtn;

@property (nonatomic,strong) UIImageView * BKLiveWhiteBKG;

@property (nonatomic,strong) UIImageView * redPoint;
@property (nonatomic,strong) BKPenLaserView * penLaserView;

@property (nonatomic,strong) BKRespondView * chatView;

@property (nonatomic,strong) WKWebView * whiteBoardWebView; //专门有一个全屏的白板

@property (nonatomic,strong) BKHandsView *handsView;

@property (nonatomic,assign) BKNewHoverButtonType hoverButtonType; //悬浮按钮样式

@property (nonatomic,assign) BKNewInteractiveViewUser interactiveUserType;

//menu按钮回调
@property (nonatomic,copy) BKinteractiveViewDidMenu didMenuBlock;
//举手取消举手回调
@property (nonatomic,copy) BKinteractiveViewHandsUpBlock handsUpBlock;

//删除画笔回调
@property (nonatomic,copy) BKinteractiveViewDidDelete didDeleteBlock;
//竖条按钮回调
@property (nonatomic,copy) BKinteractiveViewThirdDidMenu thirdDidMenuBlock;
//关闭文件窗口回调
@property (nonatomic,copy) BKinteractiveViewDidWebCloseBtn webCloseBtnBlock;
//视频移动结束frame传递bolck
@property (nonatomic,copy) BKBaseTouchMoveEnd videoMoveEndBlock;
//文件移动结束frame传递bolck
@property (nonatomic,copy) BKGestureWebViewMoveEnd fileMoveEndBlock;
//文件单击
@property (nonatomic,copy) BKBaseGestureRecognizerViewTap fileTapBlock;
//全屏或者还原回调
@property (nonatomic,copy) BKGestureWebViewLargeOrShrinkBlock largeOrShrinkBlock;
//视频点击回调
@property (nonatomic,copy) BKBaseTouchViewTap moveViewTapBlock;
//视频双击回调
@property (nonatomic,copy) BKNewInteractiveDouble moveViewDoubleTapBlock;


@property (nonatomic,copy) BKGestureWebViewDidReceiveScriptMessage               receiveScriptMessageBlock;
@property (nonatomic,copy) BKGestureWebViewRunJavaScriptAlertPanelWithMessage    runJavaScriptAlertPanelWithMessageBlock;

@property (nonatomic,copy) BKNewInteractiveViewWhiteBoardDidReceiveScriptMessage whiteBoardBlock;

@property (nonatomic,copy) BKNewInteractiveAudioBlock audioBlock;
@property (nonatomic,copy) BKNewInteractiveAudioBlock progressAudioTimeBlock;
@property (nonatomic,copy) BKNewInteractiveVideoBlock videoBlock;
@property (nonatomic,copy) BKNewInteractiveVideoBlock progressVideoTimeBlock;


#pragma mark - 私有云不显示，设置无效
-(void)hideRoomStatusView:(BOOL)hide;

//关闭页面需要处理

#pragma mark - 聊天
-(void)addChat:(BKChatModel*)model;


#pragma mark - 画笔全局状态


/**
 橡皮状态

 @return YES 橡皮开启 NO 关闭
 */
-(BOOL)getBrushWipeStatus;


/**
 编辑状态

 @return YES 编辑开启 NO 关闭
 */
-(BOOL)getBrushEditStatus;

/**
  获得画笔状态

 @return YES 画笔开启
 */
-(BOOL)getBrushStatus;


//打开画笔
-(void)openBrush;
//打开编辑
-(void)editBrush;
//关闭画笔
-(void)closeBrush;
////如果初始为编辑状态请执行这个方法
//-(void)changeEditStatus;


//打开橡皮
-(void)openWipe;

//改变按钮图片主功能按钮为橡皮
-(void)changeWipeStatusImage;

//改变按钮图片主功能按钮为编辑
-(void)changeEditStatusImage;

//改变按钮图片主功能按钮为画笔
-(void)changeBrushStatusImage;



#pragma mark - 流的视图管理方法

//添加流
-(void)addStream:(BukaStatus*)stream;

//删除流
-(void)removeStream:(BukaStatus*)stream;
-(void)removeStreamWithUser:(User*)user;
//断线重连 删除
-(void)removeAllStream;


//获取某个用户id的流视图
-(BKLiveSubView*)getStreamView:(NSString*)userId;
-(BKLiveSubView*)getStreamViewWithAid:(long)aid withVid:(long)vid;
-(BKLiveSubView *)liveSubView:(NSString*)fileID;
//所有视图恢复到上布局 ，老师端用
-(void)allStreamViewTop;

//查找台上用户是否举手显示图标
-(void)setHandUp:(User*)user withOn:(BOOL)isOn;

#pragma mark - 布局 public 设置初始还原快照的lastLayout
-(void)setVideoLayout:(VideoLayoutType)layout;


#pragma mark - 文档的视图管理方法

//添加文档，如果已经存在，就不再创建了，并且执行翻页
-(void)addFile:(BKHtmlPptModel*)file;
//恢复快照用
-(void)addFile:(BKHtmlPptModel*)file withRoomID:(NSString*)roomID;
//重连后刷新所有可见的文档包括白板画笔快照 废弃
//-(void)refreshAllBrashSnapShotWithRoomID:(NSString*)roomID;
//学生断线重连恢复
-(void)recoverySnapShot;
//学生断网删除所有文档
-(void)removeAllFile;

//加载白版 ,白板只有一个，所以直接load房间号即可刷新快照
//-(void)loadWhiteBoardWith:(NSString *)roomid;
//加载白版 ,白板只有一个，所以直接load房间号即可刷新快照
-(void)loadWhiteBoardWith:(BKRoomModel *)model;


//主动存储快照，当老师推出房间以前
//-(void)fileSaveroomID:(void (^)(BOOL complite))block;

-(void)addFileWithContentType3:(BukaStatus*)stream;
//修改文档翻页
-(void)updateFilePage:(BKHtmlPptModel*)file;
//修改文档画笔
-(void)updateBrush:(BKBrashModel *)brush;

//删除文档
-(void)removeFile:(BKHtmlPptModel*)file;
-(void)removeFileWithContentType3:(BukaStatus*)stream;


//获取所有
-(NSArray<BKLiveSubView*>*)getAllStreamView;

//获取非全屏的视频视图列表
-(NSArray<BKLiveSubView*>*)getStreamViewArr;
//可随意移动的视图在父视图中的index
-(NSArray<BKLiveSubView*>*)getStreamViewZS;

//获取全屏的视频视图列表
-(NSArray<BKLiveSubView*>*)getFullScreenStreamViewZS;

//移动的视频列表
-(NSArray<BKLiveSubView*>*)getMoveStreamViewZS;

//某个视频view置顶
-(void)streamUp:(BKLiveSubView*)view;


//获取某个文档方便上层对文档传值

//查找某个id的文档
-(BKGestureWebView *)searchFileView:(NSString*)fileID;

//把某个文档设置在最上层
-(void)setFileViewToUp:(NSString*)fileID;



//判断文档是否已经添加
//-(BOOL)isHasFile:(NSString*)pptID;


//文档快照

#pragma mark - 视频文档移动相关方法
//接收老师端信令被动移动文件
-(void)fileMove:(BKFileViewMoveModel*)fileMove;
//接收老是断信令被动移动视频窗口
-(void)videoMove:(BKVideoMoveModel*)videoMove isT:(BOOL)isTeacher;
//接收
//-(void)allVideoMove:(NSArray *)mainVideoArr;

//包括白版文档 用于画笔快照关闭 ⚠️只有白板和文档，还有media 的，没有二路流的
-(NSArray<BKGestureWebView*>*)getAllFileView;
//这个只有二路流的文档
-(NSArray<BKGestureWebView*>*)getStreamFileView;
//获得文件zx
-(NSArray<BKGestureWebView*>*)getFileViewZS;



#pragma mark - 断线重连操作
//开始断线重连
-(void)startOfflineTime;
//结束断线重连
-(void)stopOfflineTime;

@end
